<?php

/**
 * Model Class for Events 
 */
class Event {
    
    private $course;
    private $year;
    
    private $title;
    private $lecturer;
    private $location;
    private $type;
    private $start;
    private $end;
    
    /**
     * Creates Event class
     * @param String $course Three-character representation of the course this Event belongs to
     * @param int $year Four-digit representation of the class' year the Event is associated with
     */
    function __construct($course, $year){
        $this->course = $course;
        $this->year = $year;
    }
    
    public function getCourse() {
        return $this->course;
    }

    public function setCourse($course) {
        $this->course = $course;
    }

    public function getYear() {
        return $this->year;
    }

    public function setYear($year) {
        $this->year = $year;
    }

    public function getTitle() {
        return $this->title;
    }

    public function setTitle($title) {
        $this->title = $title;
    }

    public function getLecturer() {
        return $this->lecturer;
    }

    public function setLecturer($lecturer) {
        $this->lecturer = $lecturer;
    }

    public function getLocation() {
        return $this->location;
    }

    public function setLocation($location) {
        $this->location = $location;
    }

    public function getType() {
        return $this->type;
    }

    public function setType($type) {
        $this->type = $type;
    }

    public function getStart() {
        return $this->start;
    }

    public function setStart($start) {
        $this->start = $start;
    }

    public function getEnd() {
        return $this->end;
    }

    public function setEnd($end) {
        $this->end = $end;
    }
    
    public function toString(){
        return $this->title.' starting '.date("H:i", $this->start).' ('.$this->lecturer.', '.$this->location.')';
    }
    
    public function toXml(){
        $result = '<Event>';
        $result .= '<Title>'.str_replace("&", "und", $this->title).'</Title>';
        $result .= "<Lecturer>".$this->lecturer."</Lecturer>";
        $result .= "<Location>".$this->location."</Location>";
        $result .= "<Type>".$this->type."</Type>";
        $result .= "<Start>".$this->start."</Start>";
        $result .= "<End>".$this->end."</End>";
        $result .= '</Event>';
        return $result;
    }
    
}

?>
